package org.example;

/**
 * @author: knowno
 * @create: 2025-09-09 13:44
 * @Version 1.0
 **/
public class TestBasicDataType {

    //类成员 可以不初始化,默认值为0
    int n1 ;

    public static void main(String[] args) {

        // 8个基本数据类型
        byte a = 10; //字节
        short b = 100; //短整型
        int c = 1000; //整型
        long d = 10000L; //长整型,可加后缀L或者l
        float e = 1.1f; //单精度浮点数,必须要加f或者F
        double f = 1.1; //双精度浮点数,可加后缀D或者d
        char g = 'a'; //字符
        boolean h = true; //布尔型


        byte b1 = 127;
        byte b2 = -128; //字节
        System.out.println(b1);
        System.out.println(b2);

        //类型提升(byte+int)
        //1 字节+整型=整型
        byte b3 = (byte) (b1+1);
        System.out.println(b3); //-128

        byte b4 = (byte) (b2-1);
        System.out.println(b4);//127


        //局部变量赋值
        int n1 ;
//        System.out.println(n1);


        System.out.println(new TestBasicDataType().n1);


    }
}
